<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Account/classes/PhpFox_ComponentForgotPass.class.php, $Author:  $ */



/** Forgot password component
 *
 * @package module.account
 * @version $Id: PhpFox_ComponentForgotPass.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 *
 */
class PhpFox_Mod_Account_ComponentForgotPass extends BaseComponent
{

    /** Processing method
     */
	function process()
    {
        // initialisation
        $oReq = &App::getRequest();
		/* @var $oReq Request */

        $sAction = 'form';
        // processing action
        switch ($oReq->getAction())
        {
        	case 'send':
        		$sAction = 'send';
        		$oSrvSec = $this->_oModule->getService('Security');
        		/* @var $oSrvSec PhpFox_Mod_Account_ServiceSecurity */

        		if ( !$oSrvSec->sendNewPass($oReq->get('email'), $this->getParam('url_verify', 'public.forgotpass-verify')))
        		{
        			$sAction = 'form';
        			$this->addErrors($oSrvSec->getErrors());
        		}
        		else
        		{
        			$oTpl = &$this->_oModule->getTemplate();
        			$oTpl->assign('sEmail', $oReq->get('email'));
        		}
        		break;
        }

        // prepare view
        $oTpl = &$this->_oModule->getTemplate();

        $oTpl->assign(array(
            'sAction'  => $sAction,
            'aErrors'  => $this->getErrors(),
        ));

        $sHtml = $oTpl->fetch('ForgotPass.html');
        return $sHtml;
    }

}
?>